package com.shaoyu.tools.testcase;

import com.shaoyu.tools.event.core.ConcurrentWrap;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shaoyu
 * @date 2022/11/23 10:18
 */
@Configuration
public class GlobalConfig {

    public GlobalConfig() {
        System.out.println("GlobalConfig");
    }

    @Bean
    public ConcurrentWrap concurrentWrap() {
        return new ConcurrentWrap() {
            /**
             * 包装异步调用的Runnable
             *
             * @param runnable
             * @return
             */
            @Override
            public Runnable warp(Runnable runnable) {
                return () -> {
                    System.out.println("我在这里执行了某些操作.");
                    runnable.run();
                };
            }
        };
    }
}
